package com.gsoe.problem.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gsoe.problem.po.ExamRegisterUser;
import com.gsoe.problem.vo.ExamResultVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 已注册考试学生信息表 Mapper 接口
 * </p>
 *
 * @author xiaoma
 * @since 2024-10-27
 */
public interface ExamRegisterUserMapper extends BaseMapper<ExamRegisterUser> {
    @Update("update exam_register_user set status=2 where exam_id=#{examId} and user_id=#{id} and status!=2")
    Integer updateStatus(@Param("examId") Long examId,@Param("id") Long id);
    @Update("update exam_register_user set status=#{status} where exam_id=#{examId} and user_id=#{id} and status!=3")
    Integer updateStatusWithJudging(@Param("examId")Long examId, @Param("id")Long id,@Param("status") Integer status);

    @Select("select exam_register_user.exam_id from exam_register_user left join exam  on exam_register_user.exam_id = exam.id  where exam_register_user.user_id = #{userId} order by exam.create_time DESC ")
    List<Long> getExamId(Long userId);

    @Select("select id, user_id, user_name, exam_id, score, teacher_comment, ai_comment, status\n" +
            "from exam_register_user\n" +
            "where exam_id = #{examId} order by score desc")
    List<ExamRegisterUser> getExamRegisterUser(@Param("examId") Long examId);
}
